var date_arr = new Array;
var day1_arr = new Array;
var day2_arr = new Array;

date_arr[0]=new Option("Januari",1);
date_arr[1]=new Option("Februari",2);
date_arr[2]=new Option("Maret",3);
date_arr[3]=new Option("April",4);
date_arr[4]=new Option("Mei",5);
date_arr[5]=new Option("Juni",6);
date_arr[6]=new Option("Juli",7);
date_arr[7]=new Option("Agustus",8);
date_arr[8]=new Option("September",9);
date_arr[9]=new Option("Oktober",10);
date_arr[10]=new Option("November",11);
date_arr[11]=new Option("Desember",12);

function fill_select(f)
{
        document.writeln("<SELECT name=\"month1\" onchange=\"update_days1(form_pencatatan)\">");
        for(x=0;x<12;x++)
                document.writeln("<OPTION value=\""+date_arr[x].value+"\">"+date_arr[x].text);
        document.writeln("</SELECT><SELECT name=\"day1\"></SELECT>");
        selection=f.month1[f.month1.selectedIndex].value;
}

function fill_select_dft1(f)
{
        document.writeln("<SELECT name=\"month1\" onchange=\"update_days1(dft_transaksi)\">");
        for(x=0;x<12;x++)
                document.writeln("<OPTION value=\""+date_arr[x].value+"\">"+date_arr[x].text);
        document.writeln("</SELECT><SELECT name=\"day1\"></SELECT>");
        selection=f.month1[f.month1.selectedIndex].value;
}

function fill_select_dft2(f)
{
        document.writeln("<SELECT name=\"month2\" onchange=\"update_days2(dft_transaksi)\">");
        for(x=0;x<12;x++)
                document.writeln("<OPTION value=\""+date_arr[x].value+"\">"+date_arr[x].text);
        document.writeln("</SELECT><SELECT name=\"day2\"></SELECT>");
        selection=f.month2[f.month2.selectedIndex].value;
}

function update_days1(f)
{
        temp=f.day1.selectedIndex;
       
    for(x=day1_arr.length;x>0;x--)
        {
                day1_arr[x]=null;
                f.day1.options[x]=null;
         }
     
        y=parseInt(f.month1[f.month1.selectedIndex].value);
        ret_val = 0;
   
    if (y==4||y==6||y==9||y==11) {
        selection=30;
    }
    else if (y==2) {
        selection=28;
    }
    else {
        selection=31;
    }
   
        if(selection == 28)
        {
                year=parseInt(f.year1.options[f.year1.selectedIndex].value);
                if (year % 4 != 0 || year % 100 == 0 ) ret_val=0;
                else
                        if (year % 400 == 0)  ret_val=1;
                        else
                                ret_val=1;
        }
   
        selection = selection + ret_val;
        for(x=1;x < selection+1;x++)
        {
                day1_arr[x-1]=new Option(x);
                f.day1.options[x-1]=day1_arr[x-1];
        }
        if (temp == -1) f.day1.options[0].selected=true;
        else
             f.day1.options[temp].selected=true;
}


function update_days2(f)
{
        temp=f.day2.selectedIndex;
        for(x=day2_arr.length;x>0;x--)
        {
                day2_arr[x]=null;
                f.day2.options[x]=null;
         }
     
        y=parseInt(f.month2[f.month2.selectedIndex].value);
        ret_val = 0;
   
    if (y==4||y==6||y==9||y==11) {
        selection=30;
    }
    else if (y==2) {
        selection=28;
    }
    else {
        selection=31;
    }
   
        if(selection == 28)
        {
                year=parseInt(f.year2.options[f.year2.selectedIndex].value);
                if (year % 4 != 0 || year % 100 == 0 ) ret_val=0;
                else
                        if (year % 400 == 0)  ret_val=1;
                        else
                                ret_val=1;
        }
        selection = selection + ret_val;
     
    for(x=1;x < selection+1;x++) {
                day2_arr[x-1]=new Option(x);
                f.day2.options[x-1]=day2_arr[x-1];
        }
   
        if (temp == -1) f.day2.options[0].selected=true;
        else
             f.day2.options[temp].selected=true;
}

function year_install(f)
{
        document.writeln("<SELECT name=\"year1\" onchange=\"update_days1(form_pencatatan)\">")
        for(x=2009;x<2020;x++) document.writeln("<OPTION value=\""+x+"\">"+x);
        document.writeln("</SELECT>");
        update_days1(f)
}

function year_install_dft1(f)
{
        document.writeln("<SELECT name=\"year1\" onchange=\"update_days1(dft_transaksi)\">")
        for(x=2009;x<2020;x++) document.writeln("<OPTION value=\""+x+"\">"+x);
        document.writeln("</SELECT>");
        update_days1(f)
}

function year_install_dft2(f)
{
        document.writeln("<SELECT name=\"year2\" onchange=\"update_days2(dft_transaksi)\">")
        for(x=2009;x<2020;x++) document.writeln("<OPTION value=\""+x+"\">"+x);
        document.writeln("</SELECT>");
        update_days2(f)
}